<!DOCTYPE html>
<?php
	session_start();
?>
<html>
	<head>
		<meta http-equiv = "content-type" content = "text/html; charset = UTF-8">
		<title>我的主页-查看留言</title>
		<link rel = "stylesheet" href = "base.css">
		<style>
			div#content {
				width: 1190px;
				text-align: center;
				margin-top:0;
				float: left;
				
			}
			div#header {
				width: 1040px;
				text-align: center;
				float: left;
			}
			div#logo {
				width: 150px;
				float: left;
			}
			h1 {
				font-size: 18px;
			}
			a:link {
				text-decoration: none;
				color: blue;
			}
			a:visited {
				text-decoration: none;
				color: blue;
			}
			img#picture{
				text-align: center;
				margin-top: 50px;
			}
		</style>
	</head>
	<body class = "content">	
		<div id="container">
			<div id = "logo">
				<img src = "image/logo.gif"  width = "150px" height = "50px"/>
			</div>
			<div id = "header">
				<h1><a href = "index2.php">首页</a> | <a href = "msgboard.php">留言板</a> | <a href = "message.php">查看留言</a> | <a href = "userinfo.php">个人信息</a> | 
					<a href = "exit.php">退出</a></h1>
				<div id = "hello">
					<?php
					echo "$_SESSION[user] 你好！";
					?></div>
			</div>
		<div id = "content">
			<hr>
			<?php 
			include("conn.php");
			include("page.php");
			$sql = "SELECT * FROM content  order by ID DESC  limit $pageval,$pagesize "; 
			$query= mysql_query($sql); 
			while($row = mysql_fetch_array($query)) { ?>
			<table align="center"cellpadding="5" border="0" bgcolor=#add3ef width=500>
			<tr bgcolor=#eff3ff> <td>标题：<?=$row["title"]?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;用户：<?=$row["username"]?></td></tr>
			<tr bgcolor=#ffffff> <td>内容：<?=htmltocode($row["content"])?></td></tr>
			<tr bgcolor=#fffeee> <td>发布日期：<?=$row["time"]?></td></tr>
			<?php
			if($row["username"]==($_SESSION['user']) || $_SESSION['user']== "admin"){
				echo "<tr bgcolor=#fffeee><td><a href='edit.php?id=$row[id]'</a>编辑 </a>|
		     <a href=\"delete.php?id=$row[id]\" onclick=\"if(confirm('确实要删除此条留言吗？')) return true;else return false; \" >删除</a></td></tr>";
			}
			?>
			</table>
			<br>
			<?php } 
			echo "<center>共有 $num 条记录,当前第".($pageval+1)."-".($page*$pagesize)."条<br></center>";
			if($num>$pagesize){
			if($page<2){
				echo "<center>首页 上一页<a href=$url?page=".($page+1)."> 下一页</a>
				<a href=$url?page=".($pagecount).">尾页</a></center>";
			}else
			if($page==$pagecount){
				echo "<center><a href=$url?page=1>首页</a><a href=$url?page=".($page-1)."> 上一页</a> 下一页 尾页</a></center>";
			}
			else{
				echo"<center><a href=$url?page=1>首页</a><a href=$url?page=".($page-1)."> 上一页</a>
				<a href=$url?page=".($page+1)."> 下一页</a><a href=$url?page=".($pagecount).">尾页</a></center>";
			}
		}
		?>	
		</div>
		<div id="footer"><hr>Copyright © 2014 xiaolongge</div>
		</div>
	</body>
</html>